﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace simulate_control.Basic
{
    #region USING
    using simulate_control.Helpers;
    using DevComponents.DotNetBar;
    #endregion

    public partial class FrmSelectWayPointList : Form
    {
        #region VARIABLES
        public EventHandler Handler { get; set; }
        private const int OFFY = 28;
        private int FIRSTY = 9;
        private int Selected = 0;
        private Dictionary<int, string> dict = new Dictionary<int,string>();
        #endregion

        #region METHODS
        public FrmSelectWayPointList()
        {
            InitializeComponent();
        }

        public void InitDict()
        {
            dict.Add(0, "lblList");
            dict.Add(1, "lblNearest");
        }

        public void ProcessKeyEvent(KEY keyEvent)
        {
            if (keyEvent == KEY.ENTER)
            {
                this.Handler(this, new TransferDataEvent(Selected == 0 ? "LIST" : "NEAREST"));
                this.Close();
            }
            else
            {
                switch (keyEvent)
                {
                    case KEY.UP:
                        if (Selected > 0)
                        {
                            Selected--;
                        }
                        break;
                    case KEY.DOWN:
                        if (Selected < dict.Count - 1)
                        {
                            Selected++;
                        }
                        break;
                }
                Utils.ChangeSelectItem(pnlMain, dict, Selected);
            }
        }

        private void FrmSelectOptions_Load(object sender, EventArgs e)
        {
            InitDict();
            Utils.ChangeSelectItem(pnlMain, dict, 0);
        }
        #endregion
    }
}
